<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改订单')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-order-edit" th:object="${order}">
        <input id="orderId" name="orderId" type="hidden" th:field="*{orderId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">项目名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orderName" id="orderName" th:field="*{orderName}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">客户信息：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orderCustomer" id="orderCustomer" th:field="*{orderCustomer}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">项目总额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="amount" id="amount" th:field="*{amount}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">配送方式：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="distribution" id="distribution" th:field="*{distribution}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">销售人员：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="salesman" id="salesman" th:field="*{salesman}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">订单类别：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orderType" id="orderType" th:field="*{orderType}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门负责人：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="head" id="head" th:field="*{head}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                    <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "order";

    $("#form-order-edit").validate({
        onkeyup: false,
        rules:{
            orderName:{
                remote: {
                    url: prefix + "/checkOrderNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "orderId": function() {
                            return $("input[name='orderId']").val();
                        },
                        "orderName" : function() {
                            return $.common.trim($("#orderName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            /*postSort:{
                digits:true
            },*/
        },
        messages: {
            "orderName": {
                remote: "订单项目名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-order-edit').serialize());
        }
    }
</script>
</body>
</html>
